package aclass.rocksea.com.database.db;

import com.litesuits.orm.db.annotation.Column;
import com.litesuits.orm.db.annotation.Ignore;
import com.litesuits.orm.db.annotation.MapCollection;
import com.litesuits.orm.db.annotation.Mapping;
import com.litesuits.orm.db.annotation.PrimaryKey;
import com.litesuits.orm.db.annotation.Table;
import com.litesuits.orm.db.enums.AssignType;
import com.litesuits.orm.db.enums.Relation;

import java.util.ArrayList;
import java.util.UUID;

/**
 * Created by Mrw on 2017/7/5.
 *
 */

@Table("Note")
public class Note {
    @PrimaryKey(AssignType.AUTO_INCREMENT)
    @Column("_id")
    private int id;

    @Column("_Name")
    private String name;

    @Column("_UUID")
    private String uuid;

    @Column("_Sex")
    private int sex;

    @Mapping(Relation.OneToMany)
    private ArrayList<Data> list;

    public Note(String name, int sex) {
        this.uuid = UUID.randomUUID().toString();
        this.name = name;
        this.sex = sex;
    }
    public void setList(ArrayList<Data> list) {
        this.list = list;
    }

    public String getName() {
        return name;
    }

    public ArrayList<Data> getList() {
        return list;
    }

    @Table("Data")
    public static class Data{
        @PrimaryKey(AssignType.AUTO_INCREMENT)
        @Column("_id")
        private int id;
        @Column("_UUID")
        private String uuid;
        @Column("_key")
        private String key;
        @Column("_value")
        private String value;
        public Data(String uuid,String key, String value) {
            this.uuid = uuid;
            this.key = key;
            this.value = value;
        }
        @Override
        public String toString() {
            return "Data{" +
                    "id=" + id +
                    ", key='" + key + '\'' +
                    ", value='" + value + '\'' +
                    '}';
        }
    }

    public String getUuid() {
        return uuid;
    }


}
